/*
@author Aurelien Deharbe

This file is part of Cute-Client.

Cute-Client is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

Cute-Client is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License
along with Cute-Client.  If not, see <http://www.gnu.org/licenses/>.
*/

package com.cuteserver.client.examples;

import java.util.Random;

import com.cuteserver.client.CSClient;
import com.cuteserver.client.CSException;
import com.cuteserver.client.CSSession;

public class Example05Cli1 {

	public static void main(String[] args)
	{
		try {
			CSClient c = new CSClient("localhost", 5000);
			CSSession s = c.newSession("example05");
			
			Integer[] data = new Integer[10];
			
			String window = s.qss("QMainWindow()");
			s.qs("QPushButton('send data', " + window + ") -> sendbtn");
			s.qs(window + ".show()");
			
			Random rand = new Random();
			while (true) {
				for (int i = 0 ; i < 10 ; i++) {
					data[i] = rand.nextInt(9);
					System.out.print(data[i] + ", ");
				}
				System.out.println();
				s.putDataTab("<data>", data);
				Thread.sleep(3000);
			}
		}
		catch(CSException e) {
			e.print();
		}
		catch(InterruptedException e) {
			e.printStackTrace();
		}
	}
}
